/*
* Copyright (C) 2008-2009 J-P Nurmi jpnurmi@gmail.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* $Id: sessiontabwidget.h 587 2009-05-19 20:19:17Z jpnurmi $
*/

#ifndef SESSIONTABWIDGET_H
#define SESSIONTABWIDGET_H

#include "tabwidget.h"

class Session;
class MessageView;
class SessionModel;
class CommandEngine;
struct Connection;

class SessionTabWidget : public TabWidget
{
    Q_OBJECT

public:
    SessionTabWidget(Session* session, QWidget* parent = 0);

    Session* session() const;
    QStringList channels() const;

public slots:
    void openView(const QString& receiver);
    void closeCurrentView(const QString& message = QString());
    void closeView(const QString& receiver, const QString& message = QString());
    void showHelp(const QString& command = QString());

signals:
    void titleChanged(const QString& title);
    void disconnectFrom(const QString& message);

protected slots:
    /*
    void on_msgJoined(const QString& origin, const QString& channel);
    void on_msgParted(const QString& origin, const QString& channel, const QString& message);
    void on_msgQuit(const QString& origin, const QString& message);
    void on_msgNickChanged(const QString& origin, const QString& nick);
    void on_msgModeChanged(const QString& origin, const QString& receiver, const QString& mode, const QString& args);
    void on_msgTopicChanged(const QString& origin, const QString& channel, const QString& topic);
    void on_msgInvited(const QString& origin, const QString& receiver, const QString& channel);
    void on_msgKicked(const QString& origin, const QString& channel, const QString& nick, const QString& message);
    void on_msgCtcpRequestReceived(const QString& origin, const QString& request);
    void on_msgCtcpReplyReceived(const QString& origin, const QString& reply);
    void on_msgCtcpActionReceived(const QString& origin, const QString& receiver, const QString& action);
    void on_msgNumericMessageReceived(const QString& origin, uint code, const QStringList& params);
    void on_msgUnknownMessageReceived(const QString& origin, const QStringList& params);
    */

private slots:
    void send(const QString& msg);
    void tabActivated(int index);
    void delayedTabReset();
    void delayedTabResetTimeout();

private:
    void prepareView(const QString& target, bool create = true, bool highlight = true);

    QList<int> delayedIndexes;
    SessionModel* model;
    Session* sessio;
    CommandEngine* engine;
};

#endif // SESSIONTABWIDGET_H
